<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        <el-col :span="12">
            <el-form-item label="所属校区">
              <el-select v-model="dataForm.FHOME" placeholder="请选择">
                <el-option
                  v-for="item in options6"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
          <el-form-item label="课程状态" prop="FBILLSTATE">
            <el-select v-model="dataForm.FBILLSTATE" placeholder="请选择" >
              <el-option
                  v-for="item in statuslist"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="课程编号" prop="FBILLNO">
            <el-input v-model="dataForm.FBILLNO" placeholder="自动生成" disabled />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="课程类型" prop="FBILLTYPE">
            <el-select v-model="dataForm.FBILLTYPE" placeholder="请选择" :disabled="$store.getters.userInfo.manufacturer">
              <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
            <el-form-item class="required" label="课程名称" prop="FBILLNAME">
              <el-input
                v-model="dataForm.FBILLNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item class="required" label="课程学分" prop="FPOINT">
              <el-input
                v-model="dataForm.FMFPOINTMO"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        <el-col :span="12">
          <el-form-item label="授课教师" prop="FTEACH">
            <el-select v-model="dataForm.FTEACH" placeholder="请选择" :disabled="$store.getters.userInfo.manufacturer">
              <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
            </el-select>
          </el-form-item>
        </el-col>

        
        
        <el-col :span="12">
            <el-form-item class="required" label="课程备注" prop="FMEMO">
              <el-input
                v-model="dataForm.FMEMO"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          

        <el-col :span="5">
          <el-form-item label="">
            <el-button type="success" icon="el-icon-plus" @click="insert">添加一行</el-button>
            <!-- <el-button type="primary" @click="DlvCreate" :loading="loading" v-if="insertorupdate">保存</el-button> -->
            <el-button type="primary" :loading="loading">保存</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" ></el-table-column>
      <el-table-column prop="FYEAR" label="学年届" ></el-table-column>
      <el-table-column prop="FGRADE" label="所属年级"></el-table-column>
      <el-table-column prop="FCLASS" label="所属班级" ></el-table-column>
      <el-table-column prop="FSTUDNAME" label="学生姓名" ></el-table-column>
    </el-table>
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  //import ShopqueryFcuston from "@/components/ShopqueryFcuston/ShopqueryFcuston.vue"
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FHOME:"奉贤海湾校区",
          FBILLNO: "010908075465.65",
          FBILLNAME: "综合化学实验2",
          FTEACH: "秦始皇",
          FBILLTYPE: "走班课程",
          FBILLSTATE: "正常",
          FPOINT :"3",
          FMEMO: ""
        },
        rules: {
          FBILLNO: [
            { required: true, message: '请输入课程编号', trigger: 'blur' },
          ],
          FBILLNAME: [
            { required: true, message: '请输入课程名称', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "24级化学系1班",
                  "FSTUDNAME": "曹操"
                },
                { "FENTRYID":2,
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "24级化学系1班",
                  "FSTUDNAME": "刘备"
                },
                { "FENTRYID":3,
                  "FYEAR": 2024,
                  "FGRADE": "大一",
                  "FCLASS": "24级化学系1班",
                  "FSTUDNAME": "关羽"
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: 'L001',
          label: '秦始皇'
        }, {
          value: 'L002',
          label: '汉武帝'
        }, {
          value: 'L003',
          label: '唐太宗'
        }],

        //所属校区选择数据
        options2: [{
          value: 'L001',
          label: '行政班课程'
        }, {
          value: 'L002',
          label: '走班课程'
        }],

        options6: [{
          value: '10',
          label: '徐汇桂林路校区'
        }, {
          value: '20',
          label: '奉贤海湾校区'
        }],

        statuslist: [
          {
            id: 1, fullName: '正常'
          },
          {
            id: 2, fullName: '暂停'
          },
          {
            id: 3, fullName: '停课'
          }
        ],
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>